<script setup lang="ts">
import { ref } from 'vue'
import type { BannerItme } from '@/types/home'
const activeIndex = ref(0)
const changeItem: UniHelper.SwiperOnChange = (evt) => {
  activeIndex.value = evt.detail.current
}
defineProps<{
  list: BannerItme[]
}>()
</script>

<template>
  <view class="carousel">
    <swiper :circular="true" :autoplay="true" :interval="3000" @change="changeItem">
      <swiper-item v-for="item in list" :key="item.id">
        <navigator url="/pages/index/index" hover-class="none" class="navigator">
          <image mode="aspectFill" class="image" :src="item.imgUrl"></image>
        </navigator>
      </swiper-item>
    </swiper>
    <!-- 指示点 -->
    <view class="indicator">
      <text
        v-for="(item, index) in list"
        :key="item.id"
        class="dot"
        :class="{ active: index === activeIndex }"
      ></text>
    </view>
  </view>
</template>

<style lang="scss">
:host {
  display: block;
  height: 280rpx;
}
@import '@/components/style/XtxSwiper.scss';
</style>
